package com.dfrz.bookstore.service.impl;

import com.dfrz.bookstore.dao.impl.OrderDaoImpl;
import com.dfrz.bookstore.entry.Order;
import com.dfrz.bookstore.service.OrderService;

import javax.swing.*;
import java.io.IOException;
import java.sql.SQLException;
import java.util.List;

/**
 * 类功能描述:
 *
 * @Author keyan
 * @Date 2021/5/20 22:57
 */
public class OrderServiceImpl implements OrderService {
    OrderDaoImpl orderDao = new OrderDaoImpl();
    @Override
    public void inertOrder(Order order) {

        boolean flag = orderDao.insert(order);
        if (flag){
            JOptionPane.showMessageDialog(null,"订单生成成功");
        }else {
            JOptionPane.showMessageDialog(null,"订单生成失败");
        }
    }

    @Override
    public void upDataOrder(Order order) {
        boolean flag = orderDao.updateByObj(order);
        if (flag){
           JOptionPane.showMessageDialog(null,"操作成功");
        }else {
            JOptionPane.showMessageDialog(null,"操作,联系管理员");
        }

    }

    @Override
   public List<Order>  findOrderByOrder(Order order){
        List<Order> orderList = orderDao.findObjByObj(order);
        return orderList;
    }

    @Override
    public List<Order> findOrderByPage(Order order, int pageNum, int pageSize) {
        List<Order> orders = orderDao.findObjByPage(order, pageNum, pageSize);
        if (orders.size()>0){
            return orders;
        }
        return null;
    }


}
